package org.jeecg.modules.power.order.service.impl;


import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.power.order.entity.YlPowerBankOrder;
import org.jeecg.modules.power.order.mapper.YlPowerBankOrderMapper;
import org.jeecg.modules.power.order.service.IYlPowerBankOrderService;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @Description: 租借充电宝订单
 * @Author: jeecg-boot
 * @Date:   2024-07-22
 * @Version: V1.0
 */
@Service
public class YlPowerBankOrderServiceImpl extends ServiceImpl<YlPowerBankOrderMapper, YlPowerBankOrder> implements IYlPowerBankOrderService {


    /**
     * APP运营端-首页租借订单统计数量 根据日期
     * @param userIds
     * @param day  日期
     * @param type 1 今日下单  2归还充电宝
     * @return
     */
    @Override
    public Map<String, Object> getDayOrderQuantity(List<String> userIds, String day,int type) {
        String ids = String.format("'%s'", String.join("','", userIds));
        return baseMapper.getDayOrderQuantity(ids, day,type);
    }

    /**
     * APP运营端-收益页-2级页面-门店收益-门店设备收益
     * @param shopId 店铺id
     * @param dayStart 开始时间
     * @param dayEnd 结束时间
     * @return
     */
    @Override
    public Map<String, Object> getTwoShopIncomeOrder(String shopId, String dayStart, String dayEnd) {
        return baseMapper.getTwoShopIncomeOrder(shopId, dayStart, dayEnd);
    }


    /**
     *  APP运营端-收益页-2级页面-门店设备收益
     * @param shopId 店铺id
     * @param categoryId 设备类型id
     * @param type 1今日、2昨日、3本周、4本月   0全部
     * @return
     */
    @Override
    public  List<Map<String, Object>> getTwoShopDeviceOrder(List<String> userIds,String shopId, String categoryId,int type) {
        String ids = String.format("'%s'", String.join("','", userIds));
        return baseMapper.getTwoShopDeviceOrder(ids,shopId, categoryId,type);
    }

    /**
     * APP运营端-首页租借订单统计数量
     * @param userIds
     * @param type
     * @return
     */
    @Override
    public Map<String, Object> getHomePowerBankOrderQuantity(List<String> userIds, int type) {
        String ids = String.format("'%s'", String.join("','", userIds));
        return baseMapper.getHomePowerBankOrderQuantity(ids,type);
    }

    @Override
    public Map<String, Object> getHomePowerBankOrder(List<String> userIds, int type) {
        if (userIds.size()==0){//说明不是业务员
            return baseMapper.getHomePowerBankOrder(null,type);
        }
        String ids = String.format("'%s'", String.join("','", userIds));
        return baseMapper.getHomePowerBankOrder(ids,type);
    }


    /**
     * app首页租借订单统计 收益
     * @param type 1今日、2昨日、3本周、4本月   0全部
     * @return
     */
    @Override
    public Map<String, Object> getAppPowerBankOrderIncome(List<String> userIds, int type) {
        String ids = String.format("'%s'", String.join("','", userIds));
        return baseMapper.getAppPowerBankOrderIncome(ids,type);
    }

    /**
     * 获取最新更新时间 给前端接口用
     * @param userIds
     * @return
     */
    @Override
    public YlPowerBankOrder getMaxPowerBankOrder(List<String> userIds) {
        String ids = String.format("'%s'", String.join("','", userIds));
        return baseMapper.getMaxPowerBankOrder(ids);
    }

    /**
     * 给前端用 获取 时间范围数据  折线图 30天
     * 首页租借收益订单折线图
     * @param dayStart 开始时间
     * @param dayEnd  结束时间
     * @return
     */
    @Override
    public List<Map<String, Object>> getPowerBankOrderOrderDayList(List<String> userIds,Date dayStart, Date dayEnd) {

        String ids = String.format("'%s'", String.join("','", userIds));

        return baseMapper.getPowerBankOrderOrderDayList(ids,dayStart, dayEnd);
    }


    @Override
    public List<Map<String, Object>> getPowerBankOrderOrderYueList(List<String> userIds,Date dayStart, Date dayEnd) {
        String ids = String.format("'%s'", String.join("','", userIds));
        return baseMapper.getPowerBankOrderOrderYueList(ids,dayStart, dayEnd);
    }

    /**
     * APP运营端首页-求出订单硬件问题 统计 正常下单数量
     * @param mac mac
     * @param type 1今日、2昨日、3本周、4本月   0全部
     * @return
     */
    @Override
    public Integer getProblemOrderAndBankOrderOrderQuantity(String mac, int type) {
        return baseMapper.getProblemOrderAndBankOrderOrderQuantity(mac, type);
    }
}
